package lsl.leetCode.test1215;

import java.util.Arrays;

/**
 * 力扣
 * 26. 删除有序数组中的重复项
 * description:
 *
 * @author: liushengli
 * data: 2022/12/15
 */
public class test26 {
    public static void main(String[] args) {
        int[] nums = {0, 0, 1, 1, 1, 2, 2, 3, 3, 4,6,6,7,7,9,9};
        System.out.println(removeDuplicates(nums));
    }

    public static int removeDuplicates(int[] nums) {
        int n = nums.length;
        int j = 0;
        for (int i = 0; i < n; i++) {
            if (nums[i] != nums[j]) {
                nums[++j] = nums[i];
            }
        }
        return j + 1;
    }
}
